#include<iostream>

using namespace std;


int dfs(int a, int b, int c)
{
    if(a < b) return b-a+c;
	else if(a == b) return c;
    else if(a == b * 2) return c+1;
	else
	{
		if(a % 2 == 0) return dfs(a/2,b,c+1);
		else
		{
			return dfs((a+1)/2,b,c+2);
		}
	}
}


int main()
{
	int a,b;
	cin>>a>>b;
	cout<<dfs(a,b,0);
	return 0;
}
